package com.oneday.nuo.base.controller;


import com.oneday.nuo.base.entity.NuoRoleEntity;
import com.oneday.nuo.base.response.NuoResult;
import com.oneday.nuo.base.service.NuoUserRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * (NuoUserRole)表控制层
 *
 * @author liushuai
 * @since 2021-03-13 23:37:56
 */
@RestController
@RequestMapping("api/user/role")
@Api(tags = "NuoUserRoleController")
public class NuoUserRoleController {
    @Autowired
    private NuoUserRoleService nuoUserRoleService;

    @ApiOperation(value = "保存角色和用户的关联" ,  notes="保存角色和用户的关联")
    @PostMapping("saveRoleUser")
    public NuoResult saveRoleUser(@RequestBody  Map<String,Object> param){
        nuoUserRoleService.saveRoleUser(param);
        return NuoResult.buildResponseSave();
    }

    @ApiOperation(value = "通过用户id获取角色ids" ,  notes="通过用户id获取角色ids")
    @GetMapping("queryRoleIdsByUserId")
    public NuoResult<List<String>> queryRoleIdsByUserId(@RequestParam("userId") String userId){
        List<String> lists = nuoUserRoleService.queryRoleIdsByUserId(userId);
        return NuoResult.buildResponseQuery(lists);
    }


}